from libraries.logger import log


def shipping_costs(subtotal_price: int or float) -> float:
    """How Much Does Shipping Cost?
        根据购物车商品总价计算出对应的运输费用
    """
    map_li = [(float('-inf'), 40, 3.95), (40, 70, 6.95), (70, 200, 9.95), (200, 400, 19.95),
              (400, 700, 29.95), (700, 1000, 39.95), (1000, 1500, 69.95),
              (1500, 2000, 99.95), (2000, 2500, 129.95), (2500, 3000, 159.95),
              (3000, 10000, 199.95), (10000, float('inf'), 299.95)]

    if isinstance(subtotal_price, (int, float)):
        for item in map_li:
            if item[0] <= subtotal_price < item[1]:
                log.info(f"根据Subtotal：${subtotal_price} 匹配出运输费用：${item[2]}")
                return item[2]


if __name__ == '__main__':
    shipping_costs(69.0)
